package com.sugar.real.estate.module.business.dal.mysql.infocls;

import cn.hutool.core.util.StrUtil;
import com.sugar.real.estate.framework.common.pojo.PageResult;
import com.sugar.real.estate.framework.mybatis.core.mapper.BaseMapperX;
import com.sugar.real.estate.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.sugar.real.estate.module.business.controller.admin.infocls.vo.InfoClsPageReqVO;
import com.sugar.real.estate.module.business.dal.dataobject.infocls.InfoClsDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 资讯分类 Mapper
 *
 * @author Ysugar
 */
@Mapper
public interface InfoClsMapper extends BaseMapperX<InfoClsDO> {

    default PageResult<InfoClsDO> selectPage(InfoClsPageReqVO reqVO) {
        String title = reqVO.getTitleZhCn();
        return selectPage(reqVO, new LambdaQueryWrapperX<InfoClsDO>()
                .betweenIfPresent(InfoClsDO::getCreateTime, reqVO.getCreateTime())
                .nested(StrUtil.isNotBlank(title),
                        o -> o.like(InfoClsDO::getTitleZhCn, title).or().like(InfoClsDO::getTitleEnUs, title))
                .orderByDesc(InfoClsDO::getId));
    }

}